// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 

import java.sql.*;
import java.util.ResourceBundle;
import org.apache.log4j.Logger;

// Referenced classes of package com.unlimax.app.kerneos:
//            MainApp

public class DBObject {

	public DBObject() {
	}

	public int runQuery(String s) {
		int i = 0;
		String s1 = MainApp.bundle.getString("jdbc.url");
		String s2 = MainApp.bundle.getString("jdbc.username");
		String s3 = MainApp.bundle.getString("jdbc.password");
		try {
			Class.forName(MainApp.bundle.getString("jdbc.driver"));
			Connection connection = DriverManager.getConnection(s1, s2, s3);
			Statement statement = connection.createStatement();
			ResultSet resultset = statement.executeQuery(s);
			if (resultset.next())
				i = resultset.getInt(1);
			else
				i = 0;
			resultset.close();
			statement.close();
			connection.close();
		} catch (Exception exception) {
			MainApp.logger.error(exception.getMessage());
		}
		return i;
	}

	public String getMarketSegment(String s, String s1) {
		String s2 = null;
		String s3 = MainApp.bundle.getString("jdbc.url");
		String s4 = MainApp.bundle.getString("jdbc.username");
		String s5 = MainApp.bundle.getString("jdbc.password");
		String s6 = MainApp.bundle.getString((new StringBuilder()).append(s)
				.append(".market_segment").toString());
		String s7 = (new StringBuilder()).append("SELECT ANL_CODE FROM ")
				.append(s).append("_CUST_ANL_CAT WHERE CUST_CODE = '")
				.append(s1).append("' AND ANL_CAT_ID = '").append(s6)
				.append("'").toString();
		try {
			Class.forName(MainApp.bundle.getString("jdbc.driver"));
			Connection connection = DriverManager.getConnection(s3, s4, s5);
			Statement statement = connection.createStatement();
			ResultSet resultset = statement.executeQuery(s7);
			if (resultset.next())
				s2 = resultset.getString(1).trim();
			else
				s2 = MainApp.bundle.getString("other.na");
			resultset.close();
			statement.close();
			connection.close();
		} catch (Exception exception) {
			MainApp.logger.error(exception.getMessage());
		}
		return s2;
	}

	public String getDeliveryCountry(String s, String s1) {
		String s2 = null;
		String s3 = MainApp.bundle.getString("jdbc.url");
		String s4 = MainApp.bundle.getString("jdbc.username");
		String s5 = MainApp.bundle.getString("jdbc.password");
		String s6 = MainApp.bundle.getString((new StringBuilder()).append(s)
				.append(".delivery_country").toString());
		String s7 = (new StringBuilder()).append("SELECT ANL_CODE FROM ")
				.append(s).append("_CUST_ANL_CAT WHERE CUST_CODE = '")
				.append(s1).append("' AND ANL_CAT_ID = '").append(s6)
				.append("'").toString();
		try {
			Class.forName(MainApp.bundle.getString("jdbc.driver"));
			Connection connection = DriverManager.getConnection(s3, s4, s5);
			Statement statement = connection.createStatement();
			ResultSet resultset = statement.executeQuery(s7);
			if (resultset.next())
				s2 = resultset.getString(1).trim();
			else
				s2 = "ZZ";
			resultset.close();
			statement.close();
			connection.close();
		} catch (Exception exception) {
			MainApp.logger.error(exception.getMessage());
		}
		return s2;
	}

	public String getLogisticDepartment(String s, String s1) {
		String s2 = null;
		String s3 = MainApp.bundle.getString("jdbc.url");
		String s4 = MainApp.bundle.getString("jdbc.username");
		String s5 = MainApp.bundle.getString("jdbc.password");
		String s6 = MainApp.bundle.getString((new StringBuilder()).append(s)
				.append(".logistic_department").toString());
		String s7 = (new StringBuilder()).append("SELECT ANL_CODE FROM ")
				.append(s).append("_CUST_ANL_CAT WHERE CUST_CODE = '")
				.append(s1).append("' AND ANL_CAT_ID = '").append(s6)
				.append("'").toString();
		try {
			Class.forName(MainApp.bundle.getString("jdbc.driver"));
			Connection connection = DriverManager.getConnection(s3, s4, s5);
			Statement statement = connection.createStatement();
			ResultSet resultset = statement.executeQuery(s7);
			if (resultset.next())
				s2 = resultset.getString(1).trim();
			else
				s2 = MainApp.bundle.getString("other.na");
			resultset.close();
			statement.close();
			connection.close();
		} catch (Exception exception) {
			MainApp.logger.error(exception.getMessage());
		}
		return s2;
	}

	public String getSubsidiary(String s) {
		String s1 = null;
		s1 = MainApp.bundle.getString((new StringBuilder()).append(s)
				.append(".subsidiary").toString());
		return s1;
	}

	public String getSubsidiaryBuyerCode(String s, String s1) {
		String s2 = null;
		String s3 = MainApp.bundle.getString("jdbc.url");
		String s4 = MainApp.bundle.getString("jdbc.username");
		String s5 = MainApp.bundle.getString("jdbc.password");
		String s6 = MainApp.bundle.getString((new StringBuilder()).append(s)
				.append(".buyer").toString());
		String s7 = (new StringBuilder()).append("SELECT ANL_CODE FROM ")
				.append(s).append("_CUST_ANL_CAT WHERE CUST_CODE = '")
				.append(s1).append("' AND ANL_CAT_ID = '").append(s6)
				.append("'").toString();
		try {
			Class.forName(MainApp.bundle.getString("jdbc.driver"));
			Connection connection = DriverManager.getConnection(s3, s4, s5);
			Statement statement = connection.createStatement();
			ResultSet resultset = statement.executeQuery(s7);
			if (resultset.next())
				s2 = resultset.getString(1).trim();
			else
				s2 = MainApp.bundle.getString("other.na");
			resultset.close();
			statement.close();
			connection.close();
		} catch (Exception exception) {
			MainApp.logger.error(exception.getMessage());
		}
		return s2;
	}

	public String getInvoicedCustomer(String s, String s1) {
		String s2 = null;
		String s3 = MainApp.bundle.getString("jdbc.url");
		String s4 = MainApp.bundle.getString("jdbc.username");
		String s5 = MainApp.bundle.getString("jdbc.password");
		String s6 = (new StringBuilder())
				.append("SELECT CUST_CODE,INV_CUST_CODE FROM ").append(s)
				.append("_CUST WHERE CUST_CODE IN (SELECT CUST_CODE FROM ")
				.append(s).append("_SO WHERE SO_TXN_REF LIKE '").append(s1)
				.append("')").toString();
		try {
			Class.forName(MainApp.bundle.getString("jdbc.driver"));
			Connection connection = DriverManager.getConnection(s3, s4, s5);
			Statement statement = connection.createStatement();
			ResultSet resultset = statement.executeQuery(s6);
			if (resultset.next()) {
				if (resultset.getString("INV_CUST_CODE") == null)
					s2 = resultset.getString("CUST_CODE").trim();
				else
					s2 = resultset.getString("INV_CUST_CODE").trim();
			} else {
				s2 = MainApp.bundle.getString("other.na");
			}
			resultset.close();
			statement.close();
			connection.close();
		} catch (Exception exception) {
			MainApp.logger.error(exception.getMessage());
		}
		return s2;
	}

	public String getProductionSite(String s) {
		String s1 = null;
		s1 = MainApp.bundle.getString((new StringBuilder()).append(s)
				.append(".production_site").toString());
		return s1;
	}

	public String getDispatchSite(String s) {
		String s1 = null;
		s1 = MainApp.bundle.getString((new StringBuilder()).append(s)
				.append(".dispatch_site").toString());
		return s1;
	}

	public String getClinkerSite(String s) {
		String s1 = null;
		s1 = MainApp.bundle.getString((new StringBuilder()).append(s)
				.append(".clinker_site").toString());
		return s1;
	}

	public String getIncoterm(String s, String s1, Integer integer,
			Integer integer1) {
		String s2 = null;
		String s3 = MainApp.bundle.getString("jdbc.url");
		String s4 = MainApp.bundle.getString("jdbc.username");
		String s5 = MainApp.bundle.getString("jdbc.password");
		String s6 = (new StringBuilder())
				.append("SELECT ANL_CODE FROM ")
				.append(s)
				.append("_SIL_ANL_CODE WHERE ANL_CAT_ID = ")
				.append(MainApp.bundle.getString((new StringBuilder())
						.append(s).append(".incoterm").toString()))
				.append(" AND SI_ID = ").append(integer)
				.append(" AND SIL_NUM = ").append(integer1).toString();
		try {
			Class.forName(MainApp.bundle.getString("jdbc.driver"));
			Connection connection = DriverManager.getConnection(s3, s4, s5);
			Statement statement = connection.createStatement();
			ResultSet resultset = statement.executeQuery(s6);
			if (resultset.next())
				s2 = resultset.getString(1).trim();
			else
				s2 = MainApp.bundle.getString("other.na");
			if (s.equals("YSW"))
				if (s1.equals("\u9500\u552E\u8BA2\u5355(\u95F4)")
						|| s1.equals("\u9500\u552E\u8BA2\u5355(\u76F4)"))
					s2 = "FOB";
				else
					s2 = "ZZZ";
			resultset.close();
			statement.close();
			connection.close();
		} catch (Exception exception) {
			MainApp.logger.error(exception.getMessage());
		}
		return s2;
	}

	public String getCRIncoterm(String s, String s1, String s2, Integer integer) {
		String s3 = null;
		String s4 = MainApp.bundle.getString("jdbc.url");
		String s5 = MainApp.bundle.getString("jdbc.username");
		String s6 = MainApp.bundle.getString("jdbc.password");
		String s7 = (new StringBuilder())
				.append("SELECT ANL_CODE FROM ")
				.append(s)
				.append("_SOL_ANL_CODE WHERE ANL_CAT_ID = ")
				.append(MainApp.bundle.getString((new StringBuilder())
						.append(s).append(".incoterm").toString()))
				.append(" AND SO_TXN_REF = '").append(s2)
				.append("' AND SOL_NUM = ").append(integer).toString();
		try {
			Class.forName(MainApp.bundle.getString("jdbc.driver"));
			Connection connection = DriverManager.getConnection(s4, s5, s6);
			Statement statement = connection.createStatement();
			ResultSet resultset = statement.executeQuery(s7);
			if (resultset.next())
				s3 = resultset.getString(1).trim();
			else
				s3 = MainApp.bundle.getString("other.na");
			if (s.equals("YSW"))
				if (s1.equals("\u9500\u552E\u9000\u8D27\u5355(\u95F4)")
						|| s1.equals("\u9500\u552E\u9000\u8D27\u5355(\u76F4)"))
					s3 = "FOB";
				else
					s3 = "ZZZ";
			resultset.close();
			statement.close();
			connection.close();
		} catch (Exception exception) {
			MainApp.logger.error(exception.getMessage());
		}
		return s3;
	}

	public String getPackingCode(String s, String s1) {
		String s2 = null;
		String s3 = MainApp.bundle.getString("jdbc.url");
		String s4 = MainApp.bundle.getString("jdbc.username");
		String s5 = MainApp.bundle.getString("jdbc.password");
		String s6 = (new StringBuilder())
				.append("SELECT ANL_CODE FROM ")
				.append(s)
				.append("_ITEM_ANL_CAT WHERE ANL_CAT_ID = ")
				.append(MainApp.bundle.getString((new StringBuilder())
						.append(s).append(".packing_code").toString()))
				.append(" AND ITEM_CODE = '").append(s1).append("'").toString();
		try {
			Class.forName(MainApp.bundle.getString("jdbc.driver"));
			Connection connection = DriverManager.getConnection(s3, s4, s5);
			Statement statement = connection.createStatement();
			ResultSet resultset = statement.executeQuery(s6);
			if (resultset.next())
				s2 = resultset.getString(1).trim();
			else
				s2 = MainApp.bundle.getString("other.na");
			resultset.close();
			statement.close();
			connection.close();
		} catch (Exception exception) {
			MainApp.logger.error(exception.getMessage());
		}
		return s2;
	}

	public Double getTransAmount(String s, Integer integer, Integer integer1) {
		double d = 0.0D;
		String s1 = MainApp.bundle.getString("jdbc.url");
		String s2 = MainApp.bundle.getString("jdbc.username");
		String s3 = MainApp.bundle.getString("jdbc.password");
		String s4 = (new StringBuilder())
				.append("SELECT VAL FROM ")
				.append(s)
				.append("_SIL_VAL_ENTRY WHERE VLAB_ID = ")
				.append(MainApp.bundle.getString((new StringBuilder())
						.append(s).append(".value_lable").toString()))
				.append(" AND TXN_CURR_FLAG = 1 AND SI_ID = ").append(integer)
				.append(" AND SIL_NUM = ").append(integer1).toString();
		try {
			Class.forName(MainApp.bundle.getString("jdbc.driver"));
			Connection connection = DriverManager.getConnection(s1, s2, s3);
			Statement statement = connection.createStatement();
			ResultSet resultset = statement.executeQuery(s4);
			if (resultset.next())
				d = resultset.getDouble(1);
			else
				d = 0.0D;
			resultset.close();
			statement.close();
			connection.close();
		} catch (Exception exception) {
			MainApp.logger.error(exception.getMessage());
		}
		return Double.valueOf(d);
	}

	public Double getQuantity(String s, Integer integer, Integer integer1) {
		double d = 0.0D;
		String s1 = MainApp.bundle.getString("jdbc.url");
		String s2 = MainApp.bundle.getString("jdbc.username");
		String s3 = MainApp.bundle.getString("jdbc.password");
		String s4 = (new StringBuilder())
				.append("SELECT VAL FROM ")
				.append(s)
				.append("_SIL_VAL_ENTRY WHERE VLAB_ID = ")
				.append(MainApp.bundle.getString((new StringBuilder())
						.append(s).append(".quantity").toString()))
				.append(" AND SI_ID = ").append(integer)
				.append(" AND SIL_NUM = ").append(integer1).toString();
		try {
			Class.forName(MainApp.bundle.getString("jdbc.driver"));
			Connection connection = DriverManager.getConnection(s1, s2, s3);
			Statement statement = connection.createStatement();
			ResultSet resultset = statement.executeQuery(s4);
			if (resultset.next())
				d = resultset.getDouble(1);
			else
				d = 0.0D;
			resultset.close();
			statement.close();
			connection.close();
		} catch (Exception exception) {
			MainApp.logger.error(exception.getMessage());
		}
		return Double.valueOf(d);
	}

	public Double getCRTransAmount(String s, String s1, Integer integer) {
		double d = 0.0D;
		String s2 = MainApp.bundle.getString("jdbc.url");
		String s3 = MainApp.bundle.getString("jdbc.username");
		String s4 = MainApp.bundle.getString("jdbc.password");
		String s5 = (new StringBuilder())
				.append("SELECT VAL FROM ")
				.append(s)
				.append("_SOL_VAL_ENTRY WHERE VLAB_ID = ")
				.append(MainApp.bundle.getString((new StringBuilder())
						.append(s).append(".value_lable").toString()))
				.append(" AND TXN_CURR_FLAG = 1 AND SO_TXN_REF = '").append(s1)
				.append("' AND SOL_NUM = ").append(integer).toString();
		try {
			Class.forName(MainApp.bundle.getString("jdbc.driver"));
			Connection connection = DriverManager.getConnection(s2, s3, s4);
			Statement statement = connection.createStatement();
			ResultSet resultset = statement.executeQuery(s5);
			if (resultset.next())
				d = resultset.getDouble(1);
			else
				d = 0.0D;
			resultset.close();
			statement.close();
			connection.close();
		} catch (Exception exception) {
			MainApp.logger.error(exception.getMessage());
		}
		return Double.valueOf(d);
	}

	public Double getBaseAmount(String s, Integer integer, Integer integer1) {
		double d = 0.0D;
		String s1 = MainApp.bundle.getString("jdbc.url");
		String s2 = MainApp.bundle.getString("jdbc.username");
		String s3 = MainApp.bundle.getString("jdbc.password");
		String s4 = (new StringBuilder())
				.append("SELECT VAL FROM ")
				.append(s)
				.append("_SIL_VAL_ENTRY WHERE VLAB_ID = ")
				.append(MainApp.bundle.getString((new StringBuilder())
						.append(s).append(".value_lable").toString()))
				.append(" AND TXN_CURR_FLAG = 0 AND SI_ID = ").append(integer)
				.append(" AND SIL_NUM = ").append(integer1).toString();
		try {
			Class.forName(MainApp.bundle.getString("jdbc.driver"));
			Connection connection = DriverManager.getConnection(s1, s2, s3);
			Statement statement = connection.createStatement();
			ResultSet resultset = statement.executeQuery(s4);
			if (resultset.next())
				d = resultset.getDouble(1);
			else
				d = 0.0D;
			resultset.close();
			statement.close();
			connection.close();
		} catch (Exception exception) {
			MainApp.logger.error(exception.getMessage());
		}
		return Double.valueOf(d);
	}

	public Double getFreightAmount(String s, Integer integer, Integer integer1) {
		double d = 0.0D;
		String s1 = MainApp.bundle.getString("jdbc.url");
		String s2 = MainApp.bundle.getString("jdbc.username");
		String s3 = MainApp.bundle.getString("jdbc.password");
		String s4 = (new StringBuilder())
				.append("SELECT VAL FROM ")
				.append(s)
				.append("_SIL_VAL_ENTRY WHERE VLAB_ID = ")
				.append(MainApp.bundle.getString((new StringBuilder())
						.append(s).append(".freight").toString()))
				.append(" AND TXN_CURR_FLAG = 0 AND SI_ID = ").append(integer)
				.append(" AND SIL_NUM = ").append(integer1).toString();
		try {
			Class.forName(MainApp.bundle.getString("jdbc.driver"));
			Connection connection = DriverManager.getConnection(s1, s2, s3);
			Statement statement = connection.createStatement();
			ResultSet resultset = statement.executeQuery(s4);
			if (resultset.next())
				d = resultset.getDouble(1);
			else
				d = 0.0D;
			resultset.close();
			statement.close();
			connection.close();
		} catch (Exception exception) {
			MainApp.logger.error(exception.getMessage());
		}
		return Double.valueOf(d);
	}

	public Double getCRBaseAmount(String s, String s1, Integer integer) {
		double d = 0.0D;
		String s2 = MainApp.bundle.getString("jdbc.url");
		String s3 = MainApp.bundle.getString("jdbc.username");
		String s4 = MainApp.bundle.getString("jdbc.password");
		String s5 = (new StringBuilder())
				.append("SELECT VAL FROM ")
				.append(s)
				.append("_SOL_VAL_ENTRY WHERE VLAB_ID = ")
				.append(MainApp.bundle.getString((new StringBuilder())
						.append(s).append(".value_lable").toString()))
				.append(" AND TXN_CURR_FLAG = 0 AND SO_TXN_REF = '").append(s1)
				.append("' AND SOL_NUM = ").append(integer).toString();
		try {
			Class.forName(MainApp.bundle.getString("jdbc.driver"));
			Connection connection = DriverManager.getConnection(s2, s3, s4);
			Statement statement = connection.createStatement();
			ResultSet resultset = statement.executeQuery(s5);
			if (resultset.next())
				d = resultset.getDouble(1);
			else
				d = 0.0D;
			resultset.close();
			statement.close();
			connection.close();
		} catch (Exception exception) {
			MainApp.logger.error(exception.getMessage());
		}
		return Double.valueOf(d);
	}

	public String getTransCurrency(String s, Integer integer, Integer integer1) {
		String s1 = null;
		String s2 = MainApp.bundle.getString("jdbc.url");
		String s3 = MainApp.bundle.getString("jdbc.username");
		String s4 = MainApp.bundle.getString("jdbc.password");
		String s5 = (new StringBuilder())
				.append("SELECT CURR_CODE FROM ")
				.append(s)
				.append("_SIL_VAL_ENTRY WHERE VLAB_ID = ")
				.append(MainApp.bundle.getString((new StringBuilder())
						.append(s).append(".value_lable").toString()))
				.append(" AND TXN_CURR_FLAG = 1 AND SI_ID = ").append(integer)
				.append(" AND SIL_NUM = ").append(integer1).toString();
		try {
			Class.forName(MainApp.bundle.getString("jdbc.driver"));
			Connection connection = DriverManager.getConnection(s2, s3, s4);
			Statement statement = connection.createStatement();
			ResultSet resultset = statement.executeQuery(s5);
			if (resultset.next())
				s1 = resultset.getString(1).trim();
			else
				s1 = MainApp.bundle.getString("other.na");
			resultset.close();
			statement.close();
			connection.close();
		} catch (Exception exception) {
			MainApp.logger.error(exception.getMessage());
		}
		return s1;
	}

	public String getCRTransCurrency(String s, String s1, Integer integer) {
		String s2 = null;
		String s3 = MainApp.bundle.getString("jdbc.url");
		String s4 = MainApp.bundle.getString("jdbc.username");
		String s5 = MainApp.bundle.getString("jdbc.password");
		String s6 = (new StringBuilder())
				.append("SELECT CURR_CODE FROM ")
				.append(s)
				.append("_SOL_VAL_ENTRY WHERE VLAB_ID = ")
				.append(MainApp.bundle.getString((new StringBuilder())
						.append(s).append(".value_lable").toString()))
				.append(" AND TXN_CURR_FLAG = 1 AND SO_TXN_REF = '").append(s1)
				.append("' AND SOL_NUM = ").append(integer).toString();
		try {
			Class.forName(MainApp.bundle.getString("jdbc.driver"));
			Connection connection = DriverManager.getConnection(s3, s4, s5);
			Statement statement = connection.createStatement();
			ResultSet resultset = statement.executeQuery(s6);
			if (resultset.next())
				s2 = resultset.getString(1).trim();
			else
				s2 = MainApp.bundle.getString("other.na");
			resultset.close();
			statement.close();
			connection.close();
		} catch (Exception exception) {
			MainApp.logger.error(exception.getMessage());
		}
		return s2;
	}

	public String getBaseCurrency(String s, Integer integer, Integer integer1) {
		String s1 = null;
		String s2 = MainApp.bundle.getString("jdbc.url");
		String s3 = MainApp.bundle.getString("jdbc.username");
		String s4 = MainApp.bundle.getString("jdbc.password");
		String s5 = (new StringBuilder())
				.append("SELECT CURR_CODE FROM ")
				.append(s)
				.append("_SIL_VAL_ENTRY WHERE VLAB_ID = ")
				.append(MainApp.bundle.getString((new StringBuilder())
						.append(s).append(".value_lable").toString()))
				.append(" AND TXN_CURR_FLAG = 0 AND SI_ID = ").append(integer)
				.append(" AND SIL_NUM = ").append(integer1).toString();
		try {
			Class.forName(MainApp.bundle.getString("jdbc.driver"));
			Connection connection = DriverManager.getConnection(s2, s3, s4);
			Statement statement = connection.createStatement();
			ResultSet resultset = statement.executeQuery(s5);
			if (resultset.next())
				s1 = resultset.getString(1).trim();
			else
				s1 = MainApp.bundle.getString("other.na");
			resultset.close();
			statement.close();
			connection.close();
		} catch (Exception exception) {
			MainApp.logger.error(exception.getMessage());
		}
		return s1;
	}

	public String getCRBaseCurrency(String s, String s1, Integer integer) {
		String s2 = null;
		String s3 = MainApp.bundle.getString("jdbc.url");
		String s4 = MainApp.bundle.getString("jdbc.username");
		String s5 = MainApp.bundle.getString("jdbc.password");
		String s6 = (new StringBuilder())
				.append("SELECT CURR_CODE FROM ")
				.append(s)
				.append("_SOL_VAL_ENTRY WHERE VLAB_ID = ")
				.append(MainApp.bundle.getString((new StringBuilder())
						.append(s).append(".value_lable").toString()))
				.append(" AND TXN_CURR_FLAG = 0 AND SO_TXN_REF = '").append(s1)
				.append("' AND SOL_NUM = ").append(integer).toString();
		try {
			Class.forName(MainApp.bundle.getString("jdbc.driver"));
			Connection connection = DriverManager.getConnection(s3, s4, s5);
			Statement statement = connection.createStatement();
			ResultSet resultset = statement.executeQuery(s6);
			if (resultset.next())
				s2 = resultset.getString(1).trim();
			else
				s2 = MainApp.bundle.getString("other.na");
			resultset.close();
			statement.close();
			connection.close();
		} catch (Exception exception) {
			MainApp.logger.error(exception.getMessage());
		}
		return s2;
	}
}
